#include "All_Init.h"

void ALL_Init(void)
{
    // BSP
    DWT_Init(168);
    BSP_TIM1TIM6_PWMADC_Init();
    BSP_FOCPWM_Start();
    BSP_TIM3_HallIRQ_Init();
    BSP_TIM4_IRQ_Init();
    BSP_TIM5_IRQ_Init();
    BSP_ADC_Init();
    BSP_CAN_Init();
    BSP_Uart3_Receive_Init();
    BSP_DAC_Init(2047);
    UI_task_init();

    // FOC
    Foc_Task_Init();

    // LCD
    LCD_Init();
    LCD_Fill(0, 0, LCD_W, LCD_H, BLACK);
}

void default_task(void)
{
    while(1)
    {
        UI_task_loop();

        uint32_t time1 = 0, time2 = 0;

        if(HAL_GetTick() - time1 > 200)
        {
            HAL_GPIO_TogglePin(GPIOC, GPIO_PIN_13);
            time1 = HAL_GetTick();
        }

        if(HAL_GetTick() - time2 > 500)
        {
            HAL_GPIO_TogglePin(GPIOC, GPIO_PIN_14);
            time2 = HAL_GetTick();
        }
    }
}
